package com.zs.order.service;

import com.zs.order.client.UserClient;
import com.zs.order.mapper.OrderMapper;
import com.zs.order.pojo.Order;
import com.zs.order.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @projectName: hmall-parent
 * @package: com.zs.order.service
 * @className: OrderService
 * @author: zs
 * @description:
 * @date: 2023/5/12 21:40
 * @version: 1.0
 */
@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private UserClient userClient;

    public Order queryOrderById(Long orderId) {
        // 1.查询订单
        Order order = orderMapper.findById(orderId);

        //改用Feign来调用
        User user = userClient.findById(order.getUserId());
        order.setUser(user);
        // 4.返回
        return order;
    }
}
